<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        function sendClick() {
            let question = document.getElementById("question").value
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:8080/chatgpt",
                contentType: "application/json",
                data: JSON.stringify({"question":question}),
                success: function (response) {
                    console.log(response.answer);
                    let value = "<p>" + response.answer + "</p>";
                    $("#answer_list").html(value);
                },
                error: function(xhr, status, error) {
                    console.log(error);
                }
            });
        }
    </script>
</head>
<body>
<input type="text" id="question" placeholder="请输入你的问题" style="width: 255px;height: 25px; border-radius: 5px">
<button type="button" id="sendBtn" onclick="sendClick()">发送</button>
<br>
<div id="answer_list">

</div>
</body>
</html>